package BEANs;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

@ManagedBean
@SessionScoped

public class NavegationBean {
	
	@ManagedProperty (value="login.xhtml")
	private String viewedPage;
	
	@ManagedProperty (value="")
	private String error;
	
	public String getViewedPage() {
		return viewedPage;
	}
	public void setViewedPage(String viewedPage) {
		this.viewedPage = viewedPage;
	}
	
	public String getError() {
		return error;
	}
	public void setError(String error) {
		this.error = error;
	}
	
	public void cerrarSesion(){
		
		FacesContext context = FacesContext.getCurrentInstance();
		ListaTabBean listaTabBean = (ListaTabBean) context.getExternalContext().getSessionMap().get("listaTabBean");
		NavegationBean navegationBean = (NavegationBean) context.getExternalContext().getSessionMap().get("navegationBean");		
				
		LoginBean loginBean = new LoginBean();
		ClienteBean clienteBean = new ClienteBean();
		DatosPersonalesBean datosPersonalesBean = new DatosPersonalesBean();
		datosPersonalesBean.init();
		listaTabBean.setSelectedTab("1");
		navegationBean.setViewedPage("login.xhtml");
						
		context.getExternalContext().getSessionMap().put("listaTabBean", listaTabBean);
		context.getExternalContext().getSessionMap().put("loginBean", loginBean);							
		context.getExternalContext().getSessionMap().put("clienteBean", clienteBean);
		context.getExternalContext().getSessionMap().put("navegationBean", navegationBean);
		context.getExternalContext().getSessionMap().put("datosPersonalesBean", datosPersonalesBean);
		
	}

}
